import os

test_local_name1 = '375929071.png'
test_local_name2 = '375929072.png'
test_local_name3 = '375929073.png'


# TODO: I need to check if there is an exception in web and pop an already exist url from the url list


def check_if_file(local_name: str) -> bool:
    # if not os.path.exists(test_return_mkdir()+local_name):
    #     return False
    # file_stats = os.stat(test_return_mkdir()+local_name)
    # # print(file_stats.st_size)
    # if file_stats.st_size<5000:
    #     return False
    # return True

    if os.path.exists(test_return_mkdir() + local_name) and os.stat(test_return_mkdir() + local_name).st_size >= 5000:
        return True
    else:
        return False


def test_return_mkdir() -> str:
    return './tout/'


def get_a_pic(url_target: str, local_name: str) -> bool:
    temp_flag: bool = check_if_file(local_name=local_name)
    if not temp_flag:
        # get file
        return True
    else:
        return False
    # return True


if __name__ == '__main__':
    check_if_file(test_local_name1)
    check_if_file(test_local_name3)
